/*!
 @name：dom7-core
 @date: 2022.07.13
 @update:yuguoliang
 @blog: http://www.web000.cn/
 */

;(function (window, undefined) {
    var Dom7 = (function () {
        var Dom7 = function (arr) {
            var _this = this, i = 0;
            // Create array-like object
            for (i = 0; i < arr.length; i++) {
                _this[i] = arr[i];
            }
            _this.length = arr.length;
            // Return collection with methods
            return this;
        };
        var $ = function (selector, context) {
            var arr = [], i = 0;
            if (selector && !context) {
                if (selector instanceof Dom7) {
                    return selector;
                }
            }
            if (selector) {
                // String
                if (typeof selector === 'string') {
                    var els, tempParent, html = selector.trim();
                    if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
                        var toCreate = 'div';
                        if (html.indexOf('<li') === 0) toCreate = 'ul';
                        if (html.indexOf('<tr') === 0) toCreate = 'tbody';
                        if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
                        if (html.indexOf('<tbody') === 0) toCreate = 'table';
                        if (html.indexOf('<option') === 0) toCreate = 'select';
                        tempParent = document.createElement(toCreate);
                        tempParent.innerHTML = selector;
                        for (i = 0; i < tempParent.childNodes.length; i++) {
                            arr.push(tempParent.childNodes[i]);
                        }
                    } else {
                        if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) {
                            // Pure ID selector
                            els = [document.getElementById(selector.split('#')[1])];
                        } else {
                            // Other selectors
                            els = (context || document).querySelectorAll(selector);
                        }
                        for (i = 0; i < els.length; i++) {
                            if (els[i]) arr.push(els[i]);
                        }
                    }
                } else if ($.isFunction(selector)) return $(document).ready(selector)
                // Node/element
                else if (selector.nodeType || selector === window || selector === document) {
                    arr.push(selector);
                }
                //Array of elements or instance of Dom
                else if (selector.length > 0 && selector[0].nodeType) {
                    for (i = 0; i < selector.length; i++) {
                        arr.push(selector[i]);
                    }
                }
            }
            return new Dom7(arr);
        };
        Dom7.prototype = {
            // Classes and attriutes
            addClass: function (className) {
                if (typeof className === 'undefined') {
                    return this;
                }
                var classes = className.split(' ');
                for (var i = 0; i < classes.length; i++) {
                    for (var j = 0; j < this.length; j++) {
                        this[j].classList.add(classes[i]);
                    }
                }
                return this;
            },
            removeClass: function (className) {
                var classes = className.split(' ');
                for (var i = 0; i < classes.length; i++) {
                    for (var j = 0; j < this.length; j++) {
                        this[j].classList.remove(classes[i]);
                    }
                }
                return this;
            },
            hasClass: function (className) {
                if (!this[0]) return false;
                else return this[0].classList.contains(className);
            },
            toggleClass: function (className) {
                var classes = className.split(' ');
                for (var i = 0; i < classes.length; i++) {
                    for (var j = 0; j < this.length; j++) {
                        this[j].classList.toggle(classes[i]);
                    }
                }
                return this;
            },
            attr: function (attrs, value) {
                if (arguments.length === 1 && typeof attrs === 'string') {
                    // Get attr
                    if (this[0]) return this[0].getAttribute(attrs);
                    else return undefined;
                } else {
                    // Set attrs
                    for (var i = 0; i < this.length; i++) {
                        if (arguments.length === 2) {
                            // String
                            this[i].setAttribute(attrs, value);
                        } else {
                            // Object
                            for (var attrName in attrs) {
                                this[i][attrName] = attrs[attrName];
                                this[i].setAttribute(attrName, attrs[attrName]);
                            }
                        }
                    }
                    return this;
                }
            },
            removeAttr: function (attr) {
                for (var i = 0; i < this.length; i++) {
                    this[i].removeAttribute(attr);
                }
                return this;
            },
            data: function (key, value) {
                if (typeof value === 'undefined') {
                    // Get value
                    if (this[0]) {
                        var dataKey = this[0].getAttribute('data-' + key);
                        if (dataKey) return dataKey;
                        else if (this[0].dom7ElementDataStorage && (key in this[0].dom7ElementDataStorage)) return this[0].dom7ElementDataStorage[key];
                        else return undefined;
                    } else return undefined;
                } else {
                    // Set value
                    for (var i = 0; i < this.length; i++) {
                        var el = this[i];
                        if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};
                        el.dom7ElementDataStorage[key] = value;
                    }
                    return this;
                }
            },
            // Transforms
            transform: function (transform) {
                for (var i = 0; i < this.length; i++) {
                    var elStyle = this[i].style;
                    elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform;
                }
                return this;
            },
            transition: function (duration) {
                if (typeof duration !== 'string') {
                    duration = duration + 'ms';
                }
                for (var i = 0; i < this.length; i++) {
                    var elStyle = this[i].style;
                    elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
                }
                return this;
            },
            // Sizing/Styles
            width: function () {
                if (this[0] === window) {
                    return window.innerWidth;
                } else {
                    if (this.length > 0) {
                        return parseFloat(this.css('width'));
                    } else {
                        return null;
                    }
                }
            },
            outerWidth: function (includeMargins) {
                if (this.length > 0) {
                    if (includeMargins)
                        return this[0].offsetWidth + parseFloat(this.css('margin-right')) + parseFloat(this.css('margin-left'));
                    else
                        return this[0].offsetWidth;
                } else return null;
            },
            height: function () {
                if (this[0] === window) {
                    return window.innerHeight;
                } else {
                    if (this.length > 0) {
                        return parseFloat(this.css('height'));
                    } else {
                        return null;
                    }
                }
            },
            outerHeight: function (includeMargins) {
                if (this.length > 0) {
                    if (includeMargins)
                        return this[0].offsetHeight + parseFloat(this.css('margin-top')) + parseFloat(this.css('margin-bottom'));
                    else
                        return this[0].offsetHeight;
                } else return null;
            },
            offset: function () {
                if (this.length > 0) {
                    var el = this[0];
                    var box = el.getBoundingClientRect();
                    var body = document.body;
                    var clientTop = el.clientTop || body.clientTop || 0;
                    var clientLeft = el.clientLeft || body.clientLeft || 0;
                    var scrollTop = window.pageYOffset || el.scrollTop;
                    var scrollLeft = window.pageXOffset || el.scrollLeft;
                    return {
                        top: box.top + scrollTop - clientTop,
                        left: box.left + scrollLeft - clientLeft
                    };
                } else {
                    return null;
                }
            },
            css: function (props, value) {
                var i;
                if (arguments.length === 1) {
                    if (typeof props === 'string') {
                        if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
                    } else {
                        for (i = 0; i < this.length; i++) {
                            for (var prop in props) {
                                this[i].style[prop] = props[prop];
                            }
                        }
                        return this;
                    }
                }
                if (arguments.length === 2 && typeof props === 'string') {
                    for (i = 0; i < this.length; i++) {
                        this[i].style[props] = value;
                    }
                    return this;
                }
                return this;
            },
            //Dom manipulation
            each: function (callback) {
                for (var i = 0; i < this.length; i++) {
                    callback.call(this[i], i, this[i]);
                }
                return this;
            },
            html: function (html) {
                if (typeof html === 'undefined') {
                    return this[0] ? this[0].innerHTML : undefined;
                } else {
                    for (var i = 0; i < this.length; i++) {
                        this[i].innerHTML = html;
                    }
                    return this;
                }
            },
            text: function text(text) {
                if (typeof text === 'undefined') {
                    return this[0] ? this[0].textContent.trim() : null;
                }

                for (let i = 0; i < this.length; i += 1) {
                    this[i].textContent = text;
                }

                return this;
            },
            is: function (selector) {
                if (!this[0]) return false;
                var compareWith, i;
                if (typeof selector === 'string') {
                    var el = this[0];
                    if (el === document) return selector === document;
                    if (el === window) return selector === window;

                    if (el.matches) return el.matches(selector);
                    else if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
                    else if (el.mozMatchesSelector) return el.mozMatchesSelector(selector);
                    else if (el.msMatchesSelector) return el.msMatchesSelector(selector);
                    else {
                        compareWith = $(selector);
                        for (i = 0; i < compareWith.length; i++) {
                            if (compareWith[i] === this[0]) return true;
                        }
                        return false;
                    }
                } else if (selector === document) return this[0] === document;
                else if (selector === window) return this[0] === window;
                else {
                    if (selector.nodeType || selector instanceof Dom7) {
                        compareWith = selector.nodeType ? [selector] : selector;
                        for (i = 0; i < compareWith.length; i++) {
                            if (compareWith[i] === this[0]) return true;
                        }
                        return false;
                    }
                    return false;
                }

            },
            index: function () {
                if (this[0]) {
                    var child = this[0];
                    var i = 0;
                    while ((child = child.previousSibling) !== null) {
                        if (child.nodeType === 1) i++;
                    }
                    return i;
                } else return undefined;
            },
            eq: function (index) {
                if (typeof index === 'undefined') return this;
                var length = this.length;
                var returnIndex;
                if (index > length - 1) {
                    return new Dom7([]);
                }
                if (index < 0) {
                    returnIndex = length + index;
                    if (returnIndex < 0) return new Dom7([]);
                    else return new Dom7([this[returnIndex]]);
                }
                return new Dom7([this[index]]);
            },
            append: function (newChild) {
                var i, j;
                for (i = 0; i < this.length; i++) {
                    if (typeof newChild === 'string') {
                        var tempDiv = document.createElement('div');
                        tempDiv.innerHTML = newChild;
                        while (tempDiv.firstChild) {
                            this[i].appendChild(tempDiv.firstChild);
                        }
                    } else if (newChild instanceof Dom7) {
                        for (j = 0; j < newChild.length; j++) {
                            this[i].appendChild(newChild[j]);
                        }
                    } else {
                        this[i].appendChild(newChild);
                    }
                }
                return this;
            },
            prepend: function (newChild) {
                var i, j;
                for (i = 0; i < this.length; i++) {
                    if (typeof newChild === 'string') {
                        var tempDiv = document.createElement('div');
                        tempDiv.innerHTML = newChild;
                        for (j = tempDiv.childNodes.length - 1; j >= 0; j--) {
                            this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
                        }
                        // this[i].insertAdjacentHTML('afterbegin', newChild);
                    } else if (newChild instanceof Dom7) {
                        for (j = 0; j < newChild.length; j++) {
                            this[i].insertBefore(newChild[j], this[i].childNodes[0]);
                        }
                    } else {
                        this[i].insertBefore(newChild, this[i].childNodes[0]);
                    }
                }
                return this;
            },
            insertBefore: function (selector) {
                var before = $(selector);
                for (var i = 0; i < this.length; i++) {
                    if (before.length === 1) {
                        before[0].parentNode.insertBefore(this[i], before[0]);
                    } else if (before.length > 1) {
                        for (var j = 0; j < before.length; j++) {
                            before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);
                        }
                    }
                }
            },
            insertAfter: function (selector) {
                var after = $(selector);
                for (var i = 0; i < this.length; i++) {
                    if (after.length === 1) {
                        after[0].parentNode.insertBefore(this[i], after[0].nextSibling);
                    } else if (after.length > 1) {
                        for (var j = 0; j < after.length; j++) {
                            after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);
                        }
                    }
                }
            },
            next: function (selector) {
                if (this.length > 0) {
                    if (selector) {
                        if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) return new Dom7([this[0].nextElementSibling]);
                        else return new Dom7([]);
                    } else {
                        if (this[0].nextElementSibling) return new Dom7([this[0].nextElementSibling]);
                        else return new Dom7([]);
                    }
                } else return new Dom7([]);
            },
            nextAll: function (selector) {
                var nextEls = [];
                var el = this[0];
                if (!el) return new Dom7([]);
                while (el.nextElementSibling) {
                    var next = el.nextElementSibling;
                    if (selector) {
                        if ($(next).is(selector)) nextEls.push(next);
                    } else nextEls.push(next);
                    el = next;
                }
                return new Dom7(nextEls);
            },
            prev: function (selector) {
                if (this.length > 0) {
                    if (selector) {
                        if (this[0].previousElementSibling && $(this[0].previousElementSibling).is(selector)) return new Dom7([this[0].previousElementSibling]);
                        else return new Dom7([]);
                    } else {
                        if (this[0].previousElementSibling) return new Dom7([this[0].previousElementSibling]);
                        else return new Dom7([]);
                    }
                } else return new Dom7([]);
            },
            prevAll: function (selector) {
                var prevEls = [];
                var el = this[0];
                if (!el) return new Dom7([]);
                while (el.previousElementSibling) {
                    var prev = el.previousElementSibling;
                    if (selector) {
                        if ($(prev).is(selector)) prevEls.push(prev);
                    } else prevEls.push(prev);
                    el = prev;
                }
                return new Dom7(prevEls);
            },
            parent: function (selector) {
                var parents = [];
                for (var i = 0; i < this.length; i++) {
                    if (selector) {
                        if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
                    } else {
                        parents.push(this[i].parentNode);
                    }
                }
                return $($.unique(parents));
            },
            parents: function (selector) {
                var parents = [];
                for (var i = 0; i < this.length; i++) {
                    var parent = this[i].parentNode;
                    while (parent) {
                        if (selector) {
                            if ($(parent).is(selector)) parents.push(parent);
                        } else {
                            parents.push(parent);
                        }
                        parent = parent.parentNode;
                    }
                }
                return $($.unique(parents));
            },
            find: function (selector) {
                var foundElements = [];
                for (var i = 0; i < this.length; i++) {
                    var found = this[i].querySelectorAll(selector);
                    for (var j = 0; j < found.length; j++) {
                        foundElements.push(found[j]);
                    }
                }
                return new Dom7(foundElements);
            },
            children: function (selector) {
                var children = [];
                for (var i = 0; i < this.length; i++) {
                    var childNodes = this[i].childNodes;

                    for (var j = 0; j < childNodes.length; j++) {
                        if (!selector) {
                            if (childNodes[j].nodeType === 1) children.push(childNodes[j]);
                        } else {
                            if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) children.push(childNodes[j]);
                        }
                    }
                }
                return new Dom7($.unique(children));
            },
            remove: function () {
                for (var i = 0; i < this.length; i++) {
                    if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);
                }
                return this;
            },
            empty: function () {
                for (let i = 0; i < this.length; i += 1) {
                    const el = this[i];
                    if (el.nodeType === 1) {
                        for (let j = 0; j < el.childNodes.length; j += 1) {
                            if (el.childNodes[j].parentNode) {
                                el.childNodes[j].parentNode.removeChild(el.childNodes[j]);
                            }
                        }
                        el.textContent = '';
                    }
                }
                return this;
            },
            empty2: function (flag) {
                for (let i = 0; i < this.length; i += 1) {
                    const el = this[i];
                    if (el.nodeType === 1) {
                        for (let j = 0; j < el.childNodes.length; j += 1) {
                            if (flag) {
                                if (el.childNodes[j].hasChildNodes() && !!el.childNodes[j].parentNode) {
                                    el.childNodes[j].parentNode.removeChild(el.childNodes[j]);
                                }
                            } else {
                                if (el.childNodes[j].parentNode) {
                                    el.childNodes[j].parentNode.removeChild(el.childNodes[j]);
                                }
                            }
                        }
                        if (!flag) {
                            el.textContent = '';
                        }
                    }
                }
                return this;
            },
            empty3: function () {
                for (let i = 0; i < this.length; i++) {
                    const el = this[i];
                    if (el.nodeType === 1) {
                        for (let j = 0; j < el.childNodes.length; j++) {
                            if (el.childNodes[j].nodeName !== 'TEMPLATE') {
                                if (el.childNodes[j].parentNode) {
                                    el.childNodes[j].parentNode.removeChild(el.childNodes[j]);
                                }
                            }
                        }
                    }
                }
                return this;
            },
            add: function () {
                var dom = this;
                var i, j;
                for (i = 0; i < arguments.length; i++) {
                    var toAdd = $(arguments[i]);
                    for (j = 0; j < toAdd.length; j++) {
                        dom[dom.length] = toAdd[j];
                        dom.length++;
                    }
                }
                return dom;
            }
        };
        $.fn = Dom7.prototype;
        $.extend = $.fn.extend = function () {
            var options, name, src, copy, copyIsArray, clone,
                target = arguments[0] || {},
                i = 1,
                length = arguments.length,
                deep = false;
            if (typeof target === "boolean") {
                deep = target;
                target = arguments[1] || {};

                // 将i赋值为2，跳过前两个参数
                i = 2;
            }
            if (typeof target !== "object" && !$.isFunction(target)) {
                target = {};
            }
            if (length === i) {
                target = this;
                --i;
            }
            for (; i < length; i++) {
                if ((options = arguments[i]) != null) {
                    for (name in options) {
                        src = target[name];
                        copy = options[name];
                        if (target === copy) {
                            continue;
                        }
                        if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) {
                            if (copyIsArray) {
                                copyIsArray = false;
                                clone = src && $.isArray(src) ? src : [];
                            } else {
                                clone = src && $.isPlainObject(src) ? src : {};
                            }
                            target[name] = $.extend(deep, clone, copy);
                        } else if (copy !== undefined) {
                            target[name] = copy;
                        }
                    }
                }
            }
            return target;
        };
        $.fn.extend({
            ready: function (callback) {
                // need to check if document.body exists for IE as that browser reports
                // document ready when it hasn't yet created the body element
                var readyRE = /complete|loaded|interactive/;
                if (readyRE.test(document.readyState) && document.body) callback($)
                else document.addEventListener('DOMContentLoaded', function () {
                    callback($)
                }, false)
                return this;
            },
            val: function (value) {
                var ret, elem = this[0];
                if (!arguments.length) {
                    if (elem) {
                        ret = elem.value;
                        return typeof ret === "string" ? ret.replace(/\r\n/g, "") : ret == null ? "" : ret;
                    }
                    return;
                }
                return this.each(function () {
                    var val;
                    //元素不为DOM节点则返回
                    if (this.nodeType !== 1) {
                        return;
                    }
                    val = value;
                    if (val == null) {
                        val = "";
                    } else if (typeof val === "number") {
                        val += "";
                    }
                    this.value = val;
                });
            },
        });
        $.extend({
            trim: function (str) {
                return str.replace(/(^\s*)|(\s*$)/g, "");
            },
            getTouchPosition: function (e) {
                e = e.originalEvent || e; //jquery wrap the originevent
                if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend') {
                    return {
                        x: e.targetTouches[0].pageX,
                        y: e.targetTouches[0].pageY
                    };
                } else {
                    return {
                        x: e.pageX,
                        y: e.pageY
                    };
                }
            },
            parseJSON: function (data) {
                if (typeof data !== "string" || !data) {
                    return null;
                }

                // Make sure leading/trailing whitespace is removed (IE can't handle it)
                data = data.trim();

                // Attempt to parse using the native JSON parser first
                if (window.JSON && window.JSON.parse) {
                    return window.JSON.parse(data);
                }

                console.log("Invalid JSON: " + data);
            },
            isTouch: function () {
                return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch);
            },
            touchEvents: function () {
                return {
                    start: $.isTouch ? 'touchstart' : 'mousedown',
                    move: $.isTouch ? 'touchmove' : 'mousemove',
                    end: $.isTouch ? 'touchend' : 'mouseup'
                };
            },
            unique: function (arr) {
                var unique = [];
                for (var i = 0; i < arr.length; i++) {
                    if (unique.indexOf(arr[i]) === -1) unique.push(arr[i]);
                }
                return unique;
            },
            isArray: function (arg) {
                if (typeof arg === 'object') {
                    return Object.prototype.toString.call(arg) === '[object Array]';
                }
                return false;
            },
            likeArray: function (obj) {
                if (obj &&                                // o is not null, undefined, etc.
                    typeof obj === 'object' &&            // o is an object
                    isFinite(obj.length) &&               // o.length is a finite number
                    obj.length >= 0 &&                    // o.length is non-negative
                    obj.length === Math.floor(obj.length) &&  // o.length is an integer
                    obj.length < 4294967296)              // o.length < 2^32
                    return true;                        // Then o is array-like
                else
                    return false;
            },
            isObject: function (arg) {
                if (typeof arg === 'object') {
                    return Object.prototype.toString.call(arg) === '[object Object]';
                }
                return false;
            },
            isPlainObject: function (obj) {
                if (!this.isObject(obj) || obj.nodeType || this.isWindow(obj)) {
                    return false;
                }
                try {
                    if (obj.constructor && !UtilYgl.hasOwn.call(obj, "constructor") && !UtilYgl.hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
                        return false;
                    }
                } catch (e) {
                    return false;
                }
                var key;
                for (key in obj) {
                }
                return key === undefined || UtilYgl.hasOwn.call(obj, key);
            },
            isFunction: function (obj) {
                if (typeof obj === 'function') {
                    return Object.prototype.toString.call(obj) === '[object Function]';
                }
                return false;
            },
            isWindow: function (obj) {
                return obj != null && obj == obj.window;
            },
            getWindow: function (elem) {
                //如果是elem是window对象，则直接返回elem
                //否则如果elem表示整个文档，则返回elem.defaultView(即window对象)，否则返回elem.parentWindow，如果elem.parentWindow不存在则返回false
                return $.isWindow(elem) ? elem : elem.nodeType === 9 ? elem.defaultView || elem.parentWindow : false;
            },
            each: function (object, callback) {
                var i, key
                if (this.likeArray(object)) {
                    for (i = 0; i < object.length; i++)
                        if (callback.call(object[i], i, object[i]) === false) return object;
                } else {
                    for (key in object)
                        if (callback.call(object[key], key, object[key]) === false) return object;
                }
                return object;
            },
            type: function (obj) {
                var class2type = {}, toString = class2type.toString;
                $.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function (i, name) {
                    class2type["[object " + name + "]"] = name.toLowerCase();
                });
                return obj == null ? String(obj) : class2type[toString.call(obj)] || "object";
            },
            inArray: function( elem, array, i ) {
                var len,indexOf =Array.prototype.indexOf;
                if ( array ) {
                    if ( indexOf ) {
                        return indexOf.call( array, elem, i );
                    }
                    len = array.length;
                    i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
                    for ( ; i < len; i++ ) {
                        // Skip accessing in sparse arrays
                        if ( i in array && array[ i ] === elem ) {
                            return i;
                        }
                    }
                }
                return -1;
            },
        });
        $.each(["Left", "Top"], function (i, name) {    //在jQuery.fn加上.scrollLeft()和.scrollTop()方法     对于scrollLeft来说，i为0，对于scrollTop来说，i为1
            var method = "scroll" + name;
            $.fn[method] = function (val) {                //挂在实例上面
                var elem, win;
                if (val === undefined) {                        //如果没有传入val参数
                    elem = this[0];
                    if (!elem) {                                //如果没有匹配元素
                        return null;                                //则返回null
                    }
                    win = $.getWindow(elem);                    //获取window对象，如果参数elem是window对象，则返回window对象，否则返回false
                    // Return the scroll offset
                    return win ? ("pageXOffset" in win) ? win[i ? "pageYOffset" : "pageXOffset"] :
                            document.compatMode === "CSS1Compat" && win.document.documentElement[method] ||
                            win.document.body[method] :
                        elem[method];                            //用于读取window对象、document对象、元素的滚动偏移
                }
                //执行到这里，则表示是设置滚动了
                // Set the scroll offset
                return this.each(function () {                    //遍历匹配元素，设置每个元素的滚动偏移
                    win = $.getWindow(this);

                    if (win) {                                //如果是window对象，则调用scrollTo()滚动到执行的位置，该方法两个参数都是必须的。
                        win.scrollTo(
                            !i ? val : $(win).scrollLeft(),    //这两个参数是必填的
                            i ? val : $(win).scrollTop()
                        );

                    } else {
                        this[method] = val;                    //否则设置元素的scrollLeft、scrollTop属性。
                    }
                });
            };
        });
        return $;
    })();
    window.Dom7 = window.$$ = Dom7;
})(window);
